<?php

namespace app\api\controller;

use app\admin\model\Token;
use think\facade\Request;

class Code
{
    /**
     * 机器码验证
     */
    public function verify()
    {
        $token = Request::post('code');
        $row = Token::where('token', $token)->find();
        if (empty($row)){
            return result(1,'机器码不存在');
        }
        if (strtotime($row->life) <= time()){
            return result(1,'机器码已过期，过期时间：'.$row->life);
        }
        if (!$row->status){
            return result(1,'机器码已被禁用');
        }
        return result(0,'验证成功');
    }
}